#include <iostream>
#include <vector>
using namespace std;

vector<vector<int>> ans;
vector<int> track;
bool v[6];
void backtrack(vector<int>& nums){

    if(track.size() == nums.size()){
        ans.push_back(track);
        return;
    }

    for(int i=0;i<nums.size();i++){
        if(v[i]) continue;
        v[i] = 1;
        track.push_back(nums[i]);
        backtrack(nums);
        v[i] = 0;
        track.pop_back();
    }
    return;
}

vector<vector<int>> permute(vector<int>& nums) {
    backtrack(nums);
    return ans;
}